package org.fitweb.fixture;

import org.junit.Test;

import static org.junit.Assert.*;

public class WebFixtureTest {

    private WebFixture webFixture = new WebFixture();

    @Test
    public void testCanSubstituteJavaPropertiesInUserInput() {
        String result = webFixture.substituteJavaProperties("I'm running from ${user.dir}");

        assertEquals("I'm running from " + System.getProperty("user.dir"), result);
    }

    @Test
    public void testCanFixWindowsPaths() {
        String windowsPath = "C:\\windows\\system32\\secret os files\\run_slowly_and_crash_often.exe";

        assertEquals("C:/windows/system32/secret os files/run_slowly_and_crash_often.exe", webFixture.fixWindowsPath(windowsPath));
    }

    @Test
    public void testCanDeSlashifyUrls() throws Exception {
        String url = "file:///Users/chris/Projects/fitweb/tests/data/example.html";
        assertEquals("file:/Users/chris/Projects/fitweb/tests/data/example.html", webFixture.deslash(url));
    }
}
